<?php
if (isset($_SESSION['admin-login'])) {
	if (isset($_POST['post'])) {
		$id = intval($_POST['id']);
		$judul = amankan($_POST['judul']);
		$textform = amankan($_POST['textform']);
		if (strlen($judul) == 0 || strlen($textform) == 0) {
			$_SESSION['status-blog-edit'] = "Semua input harus diisi";
			header("Location: ".site()."/".$param[0]."/blog-edit/".$param[2]);
		} else {
			$slug = slugging($_POST['judul'],"blog",$id);
			db_query("UPDATE blog SET judul = '$judul', slug= '$slug' WHERE id = $id");
			$_SESSION['status-blog'] = "Blog sudah diedit";
			header("Location: ".site()."/".$param[0]."/blog");
		}
	}
} else {
	$_SESSION['status-login'] = "Log in terlebih dahulu untuk melanjutkan";
	header("Location: ".site()."/".$param[0]."/login");
}
?>